<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>用户列表</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
	#list{
		font-size: 18px;
		margin-left:20px;
		margin-top:20px;
	}
	#btn{
		float:right;
		font-size: 18px;
		margin-top:-35px;
		margin-right:25px;
	}
	ul li{
			float: left;
		}
		#flo{
			float: right;
			padding-right: 5px;
		}
	#homePage,#Prevpage,#nextPage,#Last{
		border:1px solid #eee;
			margin-right: 20px;
			padding: 5px; 
		
	}
</style>
</head>

<script type="text/javascript" src="/EasyBuy/statics/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" >
		//查看所有信息 所用列表 的函数
	$(document).ready(function (){
		$(".mem").attr("class","now");
		function list(pageIndex){
			if(pageIndex=="" || pageIndex==null ){
				$.getJSON("UserServlet","opr=select",callback);
			}else {
				$.getJSON("UserServlet","opr=select&pageIndex="+pageIndex,callback);
			}
		}
		
		function callback(data){
			
			var $table=$("#table").html("");
			$table.append("<tr><td>用户名称</td><td>真实姓名</td><td>性别</td><td>类型</td><td>操作</td></tr>");
			for(var i=0;i<data.list2.length;i++){
				var xb;     		//性别
				if(data.list2[i].sex==1){
					xb="男";
				}else {
					xb="女";
				}
				var lx;			//用户类型
				if(data.list2[i].type==1){
					lx="管理员";
				}else {
					lx="用户";
				}
				$table.append("<tr><td>"+data.list2[i].loginName+"</td><td>"+data.list2[i].userName+"</td><td>"+xb+"</td><td>"+lx+"</td><td><a class='update' href='UserServlet?opr=updateSelect&admin="+data.list2[i].loginName+"'>修改</a>&nbsp;&nbsp;&nbsp;<a class='delete' id='"+data.list2[i].id+"'>删除</a></td></tr>");
			}
			
			//首页
			$("#homePage").click(function (){
				list();
			});
			//上一页
			$("#Prevpage").click(function (){
				list(data.currPageNo-1);
			});
			//下一页
			$("#nextPage").click(function (){
				list(data.currPageNo+1);
			});
			//末页
			$("#Last").click(function (){
				list(data.totalPageCount);
			});
			
			
			//删除
			$(".delete").click(function (){
				var  sf=confirm("确定要删除么?");
				if(sf==true){
					var id =this.id;
					$.get("UserServlet","opr=delete&id="+id,call);	
					function call(data){
					if(data=="1"){
						alert("成功");
						list();
					}else {
						alert("失败");
						list();
					}
					}
				}
			});
		}
		$(".m_right").append("<ul id='flo'><li><a id='homePage'>首页</a></li><li><a id='Prevpage'>上一页</a></li><li><a id='nextPage'>下一页</a></li><li><a id='Last'>末页</a></li></ul>");
		//$(".m_right").append("<ul><li><a class='pageOne'>首页</a></li><li><a class='pageTop'>上一页</a></li><li><a class='pageNext'>下一页</a></li><li><a class='pageLast'>尾页</a></li></ul>");
		
		
		list();
	});
		
		
		
</script>
<body>
	<%@ include file="../../common/header.jsp" %>
	<%@ include file="../../common/backendHeader.jsp" %>
	
	<c:choose>
		<c:when test="${empty applicationScope.type }">
			<% 	request.getRequestDispatcher("../../UserServlet?opr=type&href=Member&href1=user").forward(request, response); %>
		</c:when>
		<c:otherwise>
			<c:if test="${applicationScope.type==1 }">
  				<%@ include file="../../common/sideMamber.jsp" %> 
			</c:if>
			<c:if test="${applicationScope.type==0 }">
				<%@ include file="../../common/sideUser.jsp" %> 
			</c:if>
		</c:otherwise>
	 </c:choose>


			<div class="m_right">
				<p id="list">用户列表</p>
				<div id="btn"><a href="backend/user/Member_User_Insert.jsp">添加用户</a></div>
				<table border="0" id="table" class="order_tab" style="width:930px;margin-top:30px; text-align:center; margin-bottom:30px;" cellspacing="0" cellpadding="0">
					
				</table>
			</div>
		<!--End 用户中心 End-->
		<!--Begin Footer Begin -->
		
		
		<%@ include file="../../common/footer.jsp" %>    <!--引入下边栏-->
		<!--End Footer End -->


</body>
</html>
